package com.lcq.springbootcreate.project.dao;

import com.lcq.springbootcreate.project.ExceptionAndEnum.MallException;
import com.lcq.springbootcreate.project.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface UserMapper {
    @Select("select * from imooc_mall_user where id=#{id}")
    User getUserById(int id);

    @Select("select * from imooc_mall_user where username=#{username}")
    User getUserByName(@Param("username")String username);
    @Insert("INSERT INTO imooc_mall_user (username,password) VALUES (#{user.username},#{user.password})")
    int insertByUser(@Param("user")User user);

    @Update("update imooc_mall_user set personalized_signature = #{user.personalized_signature} where id = #{user.id} ")
    int updateSignatureByUserId(@Param("user")User user);
    @Select("SELECT * FROM imooc_mall_user")
    List<User> getAll();
}
